package br.inf.solutions.apresentacoes.ssp.model.basics;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import br.com.vexillum.model.CommonEntityActivated;
import br.com.vexillum.model.annotations.SearchField;
import br.com.vexillum.model.annotations.Validate;
import br.com.vexillum.model.annotations.ValidatorClass;
import br.inf.solutions.apresentacoes.ssp.model.Neighborhood;

@SuppressWarnings("serial")
@ValidatorClass(validatorClass="br.inf.solutions.gestao.managementcollection.control.validators.SectorCollectionValidator")
@Entity
@Table(name="sector_address")
public class SectorAddress extends CommonEntityActivated {
	
	@OneToMany(cascade=CascadeType.ALL, targetEntity=Neighborhood.class, mappedBy="sector", fetch=FetchType.LAZY)
	private List<Neighborhood> neighborhoods;
		
	@Column(name="name", nullable=false, unique=true, updatable=true, length=200)	
	@Validate(notNull=true, min=3)
	@SearchField
	private String name;
		
	public SectorAddress(){
		this.neighborhoods = new ArrayList<Neighborhood>();		 
	}
			
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Neighborhood> getNeighborhoods() {
		return neighborhoods;
	}

	public void setNeighborhoods(List<Neighborhood> neighborhoods) {
		this.neighborhoods = neighborhoods;
	}

	@Override
	public String toString() {
		return this.name;
	}
}